/**********************************************************************
* File: character.h
* ID  : 
* Purpose: Implementation of class Character
* Date   : 2004/04/23
* Author : T.S.Yo
* Description:
**********************************************************************/

#ifndef CHARACTER_CPP
#define CHARACTER_CPP

#include <string>
#include <iostream>
#include "character.h"

// Constructor
Character::Character():score(0),curLocation(0),weightLimit(8){};

// Destructor
Character::~Character()
{inventory.clear();} 

// Get Data Member
int Character::getScore()
{return score;}

int Character::getCurLocation()
{return curLocation;}

int Character::getCurWeight()
{
    int result = 0;
    
    
    // Iteratively sum up the weight of all items in inventory
    if (!inventory.isEmpty())
    {
        inventory.gotoBeginning();
        do
        {
            result += inventory.getCursor().getWeight();
        }while( inventory.gotoNext() );
    }
    return result;
}

int Character::getWeightLimit()
{return weightLimit;}

void Character::showItems()
{inventory.showStructure();}

// Set Data Member
void Character::setScore(const int &newScore)
{score = newScore;}

void Character::setCurLocation(const int &newCurLocation)
{curLocation = newCurLocation;}

void Character::addItem(const Item &newItem)
{inventory.insert(newItem);}

void Character::dropItem(const string &itemName)
{
    Item searchItem;
    inventory.search(itemName,searchItem);
    inventory.remove();
}

bool Character::searchItem(const string &itemName, Item &searchItem)
{
     return inventory.search(itemName,searchItem);
}

#endif    //#ifndef CHARACTER_CPP

